package utill;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DButill {

	final private static String URL="jdbc:mysql://localhost:3306/crowd?serverTimezone=UTC&characterEncoding=utf8&useUnicode=true&useSSL=false";
	final private static String USER="root";
	final private static String PWD="123456";
	final private static String DRIVER="com.mysql.jdbc.Driver";
	
	protected Connection conn;
	protected PreparedStatement pst;
	protected ResultSet rs;
	
	
	
	protected void open_db() throws SQLException {
		conn=DriverManager.getConnection(URL, USER, PWD);
	}
	
	protected void close_db() {
			try {
				if (rs!=null) {
					rs.close();
				}
				if (pst!=null) {
					pst.close();
				}
				if (conn!=null) {
					conn.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
	}
	
	static {
		try {
			Class.forName(DRIVER);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

}
